<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'tce.label', default: 'Tce')}" />
        <title><g:message code="default.edit.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="body">
            <div class="cabelistlateral"><img src="${resource(dir:'images',file:'seta_cabecalho_20x20.png')}" /> Alterar TCE</div><br/>
                <div class="dialog dadospessoais">
                    <form method="post" action="${createLink(controlador:'tce', action:'update')}" >
                    <g:hiddenField name="id" value="${tceInstance?.id}" />
                    <g:hiddenField name="version" value="${tceInstance?.version}" />
                    <input type="hidden" name="solicitacao.id" value="${tceInstance?.solicitacao.id}"/>
                    <g:if test="${flash.message}">
                        <div class="message">${flash.message}</div>
                    </g:if>
                    <g:hasErrors bean="${tceInstance}">
                        <div class="errors erro">
                            <g:renderErrors bean="${tceInstance}" as="list" />
                        </div>
                    </g:hasErrors>
                    <table>
                        <tbody>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="sequencia"><g:message code="tce.sequencia.label" default="Sequência" /></label>
                                </td>
                                <td class="value ${hasErrors(bean: tceInstance, field: 'sequencia', 'errors')}">
                                  <input type="hidden" name="sequencia" value="${tceInstance?.sequencia}"/>
                                  <b style="font-weight:bold; font-size:14px;">${tceInstance?.sequencia}</b>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="dtInicio"><g:message code="tce.dtInicio.label" default="Data Início" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'dtInicio', 'errors')}">
                                   <g:datePicker name="dtInicio" precision="day" value="${tceInstance?.dtInicio}"/>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="dtFim"><g:message code="tce.dtFim.label" default="Data Fim" /></label>
                                </td>
                                <td class="value ${hasErrors(bean: tceInstance, field: 'dtFim', 'errors')}">
                                    <b style="font-weight:bold; font-size:14px;"><g:formatDate date="${tceInstance?.dtFim}" format="dd/MM/yyyy"/></b>
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="instituicaoEnsino"><g:message code="tce.instituicaoEnsino.label" default="Instituição Ensino" /></label>
                                </td>
                                <%
                                if(instituicaoEnsino){
                                    %>
                                    <td valign="top">
                                        <select name="instituicaoEnsino.id"
                                            <option value="">Selecione</option>
                                            <%
                                            for (int i=0; i<instituicaoEnsino.size(); i++){
                                                %>
                                                <option value="${instituicaoEnsino.id[i]}">${instituicaoEnsino.nome[i]}</option>
                                                <%
                                            }
                                            %>
                                        </select>
                                    </td>
                                    <%
                                }
                                %>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="curso"><g:message code="tce.curso.label" default="Curso" /></label>
                                </td>
                                <td valign="top">
                                    <select name="curso.id"
                                        <option value="">Selecione</option>
                                        <%
                                        for (int i=0; i<cursoInstance.size(); i++){
                                            %>
                                            <option value="${cursoInstance.id[i]}" <%if(cursoInstance.id[i]==tceInstance?.curso.id){%>selected<%}%>>${cursoInstance.descricao[i]}</option>
                                            <%
                                        }
                                        %>
                                    </select>
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="supNome"><g:message code="tce.supNome.label" default="Supervisor" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'supNome', 'errors')}">
                                    <g:textField name="supNome" value="${tceInstance?.supNome}" />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="supCpf"><g:message code="tce.supCpf.label" default="CPF Supervisor" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'supCpf', 'errors')}">
                                    <g:textField name="supCpf" maxlength="25" value="${tceInstance?.supCpf}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="atividades"><g:message code="tce.atividades.label" default="Atividades" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'atividades', 'errors')}">
                                    <g:textArea name="atividades" cols="40" rows="5" value="${tceInstance?.atividades}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="chSemanal"><g:message code="tce.chSemanal.label" default="Carga Horária Semanal" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'chSemanal', 'errors')}">
                                    <g:textField name="chSemanal" value="${fieldValue(bean: tceInstance, field: 'chSemanal')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="seguradora"><g:message code="tce.seguradora.label" default="Seguradora" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'seguradora', 'errors')}">
                                    <g:textField name="seguradora" maxlength="100" value="${tceInstance?.seguradora}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="nroApolice"><g:message code="tce.nroApolice.label" default="Nº Apolice" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'nroApolice', 'errors')}">
                                    <g:textField name="nroApolice" maxlength="30" value="${tceInstance?.nroApolice}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="remunera"><g:message code="tce.remunera.label" default="Remuneração" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'remunera', 'errors')}">
                                    <g:textField name="remunera" value="${fieldValue(bean: tceInstance, field: 'remunera')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="dtRescisao"><g:message code="tce.dtRescisao.label" default="Data Rescisão" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'dtRescisao', 'errors')}">
                                    <g:datePicker name="dtRescisao" precision="day" value="${tceInstance?.dtRescisao}" default="none" noSelection="['': '']" />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="rescCausa"><g:message code="tce.rescCausa.label" default="Causa Rescisão" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'rescCausa', 'errors')}">
                                    <g:textField name="rescCausa" size="51" value="${fieldValue(bean: tceInstance, field: 'rescCausa')}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="obsCausa"><g:message code="tce.obsCausa.label" default="Obs Causa" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: tceInstance, field: 'obsCausa', 'errors')}">
                                    <g:textArea name="obsCausa" cols="40" rows="5" value="${tceInstance?.obsCausa}" />
                                </td>
                            </tr>
                        
                            <tr>
                              <td></td>
                              <td class="btsalvarcadastro">
                                  <g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" />
                                  <%
                                  if(tceInstance.situacao == '0'){
                                      %>
                                      <input type="button" name="gerar" value="GERAR TCE" onclick="location.href='${createLink(controller:'tce', action:'gerarTce', id:tceInstance?.id)}';"/>
                                      <%
                                  }else if(tceInstance.situacao == '1'){
                                      %>
                                      <input type="button" name="gerar" value="BLOQUEAR TCE" onclick="location.href='${createLink(controller:'tce', action:'gerarTce', id:tceInstance?.id)}';"/>
                                      <g:actionSubmit action="rescindirTce" value="RESCINDIR TCE" />
                                      <%
                                  }
                                  %>
                              </td>
                            </tr>

                        </tbody>
                    </table>
                </form>
            </div>

            <div class="dadoslateral">
                <div class="contatos">
                <h1 class="cabelistlateral">Remuneração</h1>
                <g:hasErrors bean="${tceRemuneraInstance}">
                <div class="errors">
                    <g:renderErrors bean="${tceRemuneraInstance}" as="list" />
                </div>
                </g:hasErrors>
                <%
                if(tceRemuneraInstance?.id){
                    %>
                    <form method="post" action="${createLink(controller:'tceRemunera', action:'update', id:tceRemuneraInstance?.id)}">
                    <%
                }else{
                    %>
                    <form method="post" action="${createLink(controller:'tceRemunera', action:'save')}">
                    <%
                }
                %>
                    <input type="hidden" name="tce.id" value="${tceInstance.id}"/>
                    <div class="dialog">
                        <table>
                            <tbody>
                                <tr class="prop cadastrolateral">
                                    <td valign="top" class="name" class="value ${hasErrors(bean: tceRemuneraInstance, field: 'dtInicio', 'errors')}">
                                        <label for="dtInicio"><g:message code="tceRemunera.dtInicio.label" default="Data Início" /></label>
                                        <br/>
                                        <g:datePicker name="dtInicio" precision="day" value="${tceRemuneraInstance?.dtInicio}"  />
                                    </td>
                                    <td valign="top" class="name" class="value ${hasErrors(bean: tceRemuneraInstance, field: 'remuneracao', 'errors')}">
                                        <label for="remuneracao"><g:message code="tceRemunera.remuneracao.label" default="Remuneracao" /></label>
                                        <br/>
                                        <g:textField name="remuneracao" value="${fieldValue(bean: tceRemuneraInstance, field: 'remuneracao')}" />
                                    </td>
                                </tr>

                                <tr class="prop cadastrolateral">
                                    <td class="btsalvarlateral">
                                      <g:submitButton name="create" class="save" value="SALVAR" />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </form>
                </div>
                <%
                if(tceRemuneraInstanceList){
                    %>
                    <div class="list">
                        <table>
                            <thead>
                                <tr>
                                    <g:sortableColumn property="dtInicio" title="${message(code: 'tceRemunera.dtInicio.label', default: 'Dt Inicio')}" />
                                    <g:sortableColumn property="remuneracao" title="${message(code: 'tceRemunera.remuneracao.label', default: 'Remuneracao')}" />
                                    <td class="acao" colspan="2">Ações</td>
                                </tr>
                            </thead>
                            <tbody>
                            <g:each in="${tceRemuneraInstanceList}" status="i" var="tceRemuneraInstance">
                                <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                                    <td><g:formatDate date="${tceRemuneraInstance.dtInicio}" /></td>
                                    <td>${fieldValue(bean: tceRemuneraInstance, field: "remuneracao")}</td>
                                    <td class="ico">
                                        <a href="${createLink(controller:'tceRemunera', action:'edit', id:tceRemuneraInstance.id, params:[tce:tceInstance.id])}">
                                            <img src="${resource(dir:'images',file:'ico_edit.png')}" alt="Editar" title="Editar" action="edit"/>
                                        </a>
                                    </td>
                                    <td class="ico">
                                        <a href="${createLink(controller:'tceRemunera', action:'delete', id:tceRemuneraInstance.id, params:[tce:tceInstance.id])}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Confirma aexclusão do registro?')}');">
                                            <img src="${resource(dir:'images',file:'ico_delete.png')}" alt="Excluir" title="Excluir" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}"  />
                                        </a>
                                    </td>
                                </tr>
                            </g:each>
                            </tbody>
                        </table>
                    </div>
                    <div class="paginateButtons">
                        <g:paginate total="${tceRemuneraInstanceTotal}" />
                    </div>
                    <%
                }else{
                    %>
                    <div class="list">Nenhuma remuneração encontrada.</div>
                    <%
                }
                %>
          </div>

          <div class="dadoslateral">
            <g:include  view="includes/inc_pagamento.gsp" params="[controlador:'tce', acao:'edit']"/>
          </div>

          <div class="dadoslateral">
              <div class="contatos">
              <h1 class="cabelistlateral">Plano de Estágio</h1>
              <g:hasErrors bean="${planoEstagioInstance}">
              <div class="errors">
                  <g:renderErrors bean="${planoEstagioInstance}" as="list" />
              </div>
              </g:hasErrors>
              <%
              if(planoEstagioInstance?.id){
                  %>
                  <form method="post" action="${createLink(controller:'planoEstagio', action:'update', id:planoEstagioInstance?.id)}">
                  <%
              }else{
                  %>
                  <form method="post" action="${createLink(controller:'planoEstagio', action:'save')}">
                  <%
              }
              %>
                  <input type="hidden" name="tce.id" value="${tceInstance.id}"/>
                  <div class="dialog">
                      <table>
                          <tbody>

                            <tr class="prop cadastrolateral">
                                <td colspan="3" valign="top" class="name" class="value ${hasErrors(bean: planoEstagioInstance, field: 'setores', 'errors')}">
                                    <label for="setores"><g:message code="planoEstagio.setores.label" default="Setores" /></label>
                                    <br/>
                                    <g:textField name="setores" maxlength="45" size="59" value="${planoEstagioInstance?.setores}" />
                                </td>
                            </tr>

                            <tr class="prop cadastrolateral">
                                <td colspan="3" valign="top" class="name" class="value ${hasErrors(bean: planoEstagioInstance, field: 'objetivos', 'errors')}">
                                    <label for="objetivos"><g:message code="planoEstagio.objetivos.label" default="Objetivos" /></label>
                                    <br/>
                                    <g:textArea name="objetivos" cols="45" rows="2" value="${planoEstagioInstance?.objetivos}" />
                                </td>
                            </tr>

                            <tr class="prop cadastrolateral">
                                <td colspan="3" valign="top" class="name" class="value ${hasErrors(bean: planoEstagioInstance, field: 'infoComplementar', 'errors')}">
                                    <label for="infoComplementar"><g:message code="planoEstagio.infoComplementar.label" default="Informações Complementar" /></label>
                                    <br/>
                                    <g:textArea name="infoComplementar" cols="45" rows="2" value="${planoEstagioInstance?.infoComplementar}" />
                                </td>
                            </tr>

                            <tr class="prop cadastrolateral">
                                <td valign="top" class="name" class="value ${hasErrors(bean: planoEstagioInstance, field: 'dtAssinaSuperior', 'errors')}">
                                    <label for="dtAssinaSuperior"><g:message code="planoEstagio.dtAssinaSuperior.label" default="Dats Assina Superior" /></label>
                                    <g:datePicker name="dtAssinaSuperior" precision="day" value="${planoEstagioInstance?.dtAssinaSuperior}" default="none" noSelection="['': '']" />
                                </td>
                                <td valign="top" class="name" class="value ${hasErrors(bean: planoEstagioInstance, field: 'dtAssinaEstagiario', 'errors')}">
                                    <label for="dtAssinaEstagiario"><g:message code="planoEstagio.dtAssinaEstagiario.label" default="Data Assina Estagiário" /></label>
                                    <br/>
                                    <g:datePicker name="dtAssinaEstagiario" precision="day" value="${planoEstagioInstance?.dtAssinaEstagiario}" default="none" noSelection="['': '']" />
                                </td>
                                <td class="btsalvarlateral">
                                    <g:submitButton name="create" class="save" value="SALVAR" />
                                </td>
                              </tr>
                          </tbody>
                      </table>
                  </div>
              </form>
              </div>
              <%
              if(planoEstagioInstanceList){
                  %>
                  <div class="list">
                      <table>
                          <thead>
                              <tr>
                                  <g:sortableColumn property="setores" title="${message(code: 'planoEstagio.setores.label', default: 'Setores')}" />
                                  <g:sortableColumn property="dtAssinaSuperior" title="${message(code: 'planoEstagio.dtAssinaSuperior.label', default: 'Dt Assina Superior')}" />
                                  <g:sortableColumn property="dtAssinaEstagiario" title="${message(code: 'planoEstagio.dtAssinaEstagiario.label', default: 'Dt Assina Estagiario')}" />
                                  <td class="acao" colspan="2">Ações</td>
                              </tr>
                          </thead>
                          <tbody>
                          <g:each in="${planoEstagioInstanceList}" status="i" var="planoEstagioInstance">
                              <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                                  <td>${fieldValue(bean: planoEstagioInstance, field: "setores")}</td>
                                  <td><g:formatDate date="${planoEstagioInstance.dtAssinaSuperior}" format="dd-MM-yyyy"/></td>
                                  <td><g:formatDate date="${planoEstagioInstance.dtAssinaEstagiario}" format="dd-MM-yyyy"/></td>
                                  <td class="ico">
                                      <a href="${createLink(controller:'planoEstagio', action:'edit', id:planoEstagioInstance.id, params:[tce:tceInstance.id])}">
                                          <img src="${resource(dir:'images',file:'ico_edit.png')}" alt="Editar" title="Editar"/>
                                      </a>
                                  </td>
                                  <td class="ico">
                                      <a href="${createLink(controller:'planoEstagio', action:'delete', id:planoEstagioInstance.id, params:[tce:tceInstance.id])}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Confirma a exclusão do registro?')}');">
                                          <img src="${resource(dir:'images',file:'ico_delete.png')}" alt="Excluir" title="Excluir"/>
                                      </a>
                                  </td>
                              </tr>
                          </g:each>
                          </tbody>
                      </table>
                  </div>
                  <div class="paginateButtons">
                      <g:paginate total="${planoEstagioInstanceTotal}" />
                  </div>
                  <%
              }else{
                  %>
                  <div class="list">Nenhuma Plano de Estágio encontrado.</div>
                  <%
              }
              %>
          </div>

        </div>
    </body>
</html>
